import { $put, $get } from '@js/authRequest'

// 更新送达
export async function updateServiceRequest (id, data) {
  const res = await $put(`/api/xapc/deliver/${id}`, data)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 获取邮单信息
export async function getEmsInfosRequest (code, caseid) {
  const res = await $get(`/api/xapc/deliver/ems/${code}`, {
    caseid
  })
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 获取送达时间
export async function getSendTimeRequest (emscode) {
  const res = await $get(`/api/xapc/ems/getArriveDatetimeByEmscode/${emscode}`)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 获取pdf地址
export async function getPdfRequest (emscode, caseid) {
  const res = await $get('/api/xapc/ems/getEmstracesDocument', {
    emscode,
    caseid
  })
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}
